var siloseer_Sidebar_Handle = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].getService(Components.interfaces.nsIWindowWatcher);
Components.utils.import("resource://siloseer_gui/siloseer_shared.js");

function add_domain()
{
	var url = document.getElementById("Domain_Url").value;
	var d = document.getElementById("Domain_Description").value;
	
	var domain_hash = new Array();
	var dummy = [];
	
	domain_hash['url'] = url;
	domain_hash['desc'] = d;
	domain_hash['data']=[];
	domain_hash['links']=new Array("nav","content");
	domain_hash['links']['nav']=[];
	domain_hash['links']['nav_xpath']=[];
	domain_hash['links']['content']=[];
	domain_hash['links']['content_xpath']=[];
	
	domains.push(domain_hash);
	nodeHash.push(dummy);
	foundArray.push(domains.length-1);
	foundArray[domains.length-1]=new Array();
	
	var label_child = elementsById('clone_Label_Name');
	var type_child = elementsById('clone_Label_Type');
	
	var data_array = new Array();
	
	//get all added labels data
	for(var i=0;i<label_child.length;i++)
	{
		var label_array = new Array();
		
		label_array['name'] = label_child[i].value;
		label_array['type'] = type_child[i].label;
		label_array['nodes'] = [];
		label_array['xpath'] = [];
		
		data_array.push(label_array);
	}
	
	domains[domains.length-1]['data']=data_array; // what does this do?
	
	
//	alert('name is '+domains[0]['url']);
	//alert('desc is '+domains[0]['desc']);
	var array1 = domains[0]['data'][0];
	//alert('len is ' + domains.length);
	
	//alert('len is ' + array1.length);
	//for(var k in array1)
		//alert('data is ' + domains[0]['data'][0][k]);
	
	
}

function moreFields() {
        
        var newFields = document.getElementById('readroot').cloneNode(true);
        
        newFields.id = 'clonereadroot';
        newFields.style.display = 'block';
        
        var newField = newFields.childNodes;
        
		
        for (var i=0;i<newField.length;i++) {
                var theName = newField[i].id;
                if (theName)
                        newField[i].id = "clone_" + theName;

                // if(newField[i].tagName == "menulist")
                 //{
					// newField[i].childNodes[0].id = "clone_Label_Type";
				// }                 
                 
        }
        
        var insertHere = document.getElementById('writeroot');
        insertHere.parentNode.insertBefore(newFields,insertHere);
}

